﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Json内容查看器</title>
    <link href="../third/jsoneditor/jsoneditor.css" rel="stylesheet" type="text/css">
    <script src="../third/jsoneditor/jsoneditor.min.js"></script>
    <style>
        #jsoneditor {
            min-height: 200px;
            height: 400px;
        }
    </style>

</head>
<body>
    <div style="margin: 0 auto;height: auto;width: 100%;overflow: hidden">
        <div style="margin-left: 2px;padding-bottom: 10px;">
            <div style="padding: 5px 4px; font-size: 12px;">服务接口地址:<input id="url" style="width: 400px; padding: 2px;"/><button style="margin-left: 2px;">请求访问</button></div>
            <div id="JsonData" style="width: 100%; min-height: 200px;height: 250px;"></div>
        </div>

        <div style="clear:both;margin-left: 2px;  background-color: rgba(224, 224, 224, 0.22)">
            <div id="Result" style="width: 100%; height:auto;"></div>
        </div>
    </div>
    <script src="../lib/require.js"></script>
    <script>
        require(["ladder-core"],function(Ladder){
            Ladder.CrossDomain=true;
            var baseData = {
                tableName:"",
                option:1,
                bean:{
                    id:1,
                    name:"nhao"
                },
                condition:{
                    id:1
                }
            }
            var container = Ladder.dom("JsonData");
            var options = {
                mode: 'code',
                modes: ['code', 'form', 'text', 'tree', 'view'], // allowed modes
                onError: function (err) {
                    alert(err.toString());
                },
                onModeChange: function (newMode, oldMode) {
                    console.log('Mode switched from', oldMode, 'to', newMode);
                }
            };
            window.editor = new JSONEditor(container, options);
            editor.set(baseData);
            window.outResult = new JSONEditor(Ladder.dom("Result"), {
                mode: 'tree',
            });
            var url = Ladder.getStore("debugurl");
            if (url) {
                $("#url").val(url);
            } else {
                $("#url").val("http://localhost:22421/ServiceCharge/CountServiceCharge");
            }
            setTimeout(function(){
                $(".jsoneditor-poweredBy").html("请求参数").attr("href","#");
            },150);
            $("button").click(function () {
                var data = Ladder.toJSON(editor.getText());
                Ladder.setStore("debugurl", $("#url").val());
                webajax($("#url").val(), Ladder.toJSON(editor.getText()), function (result) {
                    outResult.set(result);
                },"json");
            });
        });
    </script>

</body>
</html>




